package com.strp.mptcp.websocket;

import org.jetbrains.annotations.NotNull;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.AbstractWebSocketHandler;

/**
 * @author 曹行阳
 * @version 0.1
 * @date 2025/6/12 11:37
 */
public class StatsWebSocketHandler extends AbstractWebSocketHandler {
    private final WebSocketManager webSocketManager;

    public StatsWebSocketHandler(WebSocketManager webSocketManager) {
        this.webSocketManager = webSocketManager;
    }

    @Override
    public void afterConnectionEstablished(@NotNull WebSocketSession session) {
        webSocketManager.addSession(session);
    }

    @Override
    public void afterConnectionClosed(@NotNull WebSocketSession session, @NotNull CloseStatus status) {
        webSocketManager.removeSession(session);
    }
}
